package main

import (
	"fmt"
	log "github.com/cihub/seelog"
	"github.com/robfig/cron"
	"os"
	"time"
)

var (
	ttt int
)

//  https://www.cnblogs.com/shiluoliming/p/8310725.html
//  go语言 robfig/cron包 实现定时 调用 - 失落的黎明 - 博客园
func main() {
	fmt.Println(os.Getenv("GOPATH"))
	ttt = 1
	c := cron.New()
	c.AddFunc("0/5 * * * * ?", func() { log.Info("Every hour on the half hour") })
	c.AddFunc("0/5 21 * * * ?", func() { log.Info("21分") })
	c.AddFunc("0/5 * * * * ?", test) //5秒执行一次，12×5=60，所以一共执行12次
	c.Start()
	//log.Info("Every hour on the half hour")
	time.Sleep(time.Minute) //一分钟后主线程退出
	fmt.Println("aaa")
}

func test() {

	fmt.Printf("test=%d\n", ttt)
	ttt++
}
